package cn.wangwang.controller;

import cn.wangwang.dto.User;
import cn.wangwang.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by Wangwang on 2017/11/23.
 */
@Controller
@EnableAutoConfiguration
@RequestMapping("/test")
public class HelloWorldController {

    @Autowired
    private IUserService userService;

    @Autowired
    public HelloWorldController(IUserService userService) {
        this.userService = userService;
    }

    @RequestMapping("/helloWorld")
    public String sayHello() {
        return "helloWorld";
    }

    @RequestMapping("/showJsonResult")
    @ResponseBody
    public User showJsonResult() {
        return userService.getUserInfo();
    }

    @Value("${spring.thymeleaf.suffix}")
    private String valueInfo;
    @RequestMapping("/showPage")
    public String showPage(){
        System.out.println("加载的属性为:"+valueInfo);
        return "test";
    }
    @RequestMapping("/showAccount")
    public User getAccount() {
        User user = User.create();
        user.setUserName("王望");
        user.setUserPassword("12345");
        return user;
    }

}
